package com.tronsis.distribution.activity.me.order;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.flyco.tablayout.SlidingTabLayout;
import com.tronsis.distribution.R;
import com.tronsis.distribution.fragment.stock.MyStockFragment;
import com.tronsis.distribution.util.StateUtil;
import com.tronsis.library.activity.ToolBarBaseActivity;
import com.tronsis.library.adapter.SimpleViewPagerAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 我的进货
 */
public class MyStockActivity extends ToolBarBaseActivity {
    @BindView(R.id.tab_layout)
    SlidingTabLayout mTabLayout;
    @BindView(R.id.viewpager)
    ViewPager mViewPager;

    private List<Fragment> mPageList = new ArrayList<Fragment>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_stock);

        setTitle(true, getString(R.string.my_stock));

        Fragment unPayFragment = MyStockFragment.create(StateUtil.MY_STOCK_ORDER_PAY);
        Fragment auditFragment =  MyStockFragment.create(StateUtil.MY_STOCK_ORDER_VERIFY);
        Fragment stockFinishFragment =  MyStockFragment.create(StateUtil.MY_STOCK_ORDER_FINISH);
        Fragment stockUnPassFragment =  MyStockFragment.create(StateUtil.MY_STOCK_ORDER_REJECT);

        mPageList.add(unPayFragment);
        mPageList.add(auditFragment);
        mPageList.add(stockFinishFragment);
        mPageList.add(stockUnPassFragment);


        SimpleViewPagerAdapter adapter = new SimpleViewPagerAdapter(getSupportFragmentManager(), mPageList);
        mViewPager.setAdapter(adapter);

        String[] mTitles = {"待付款", "待审核", "已完成", "未通过"};
        mTabLayout.setViewPager(mViewPager, mTitles);

        int index = getIntent().getIntExtra("index", 0);
        mViewPager.setCurrentItem(index);
    }

}
